/*
 * @Author: czy
 * @Date: 2021-05-21 14:30:38
 * @LastEditTime: 2021-07-15 09:36:51
 */
#include "../lib/hook.h"

static int get_tskId(void)
{
    static int i = 1;
    return i++;
}

/**
 * @description: The timer is set to execute the function at a fixed time interval.
 * @param interval  Interval time.
 * @return Task ID.
 */
int timer(void (*func)(void), int interval)
{
    hook h = {0, interval, -1, get_tskId(), func};
    submit(h);
    return h.tskId;
}

/**
 * @description: Call the function after the specified millisecond count.
 * @param interval  Interval time.
 * @return Task ID.
 */
int setTimeout(void (*func)(void), int interval)
{
    hook h = {0, interval, 1, get_tskId(), func};
    submit(h);
    return h.tskId;
}

void cancelTsk(int tskId)
{
    cancel(tskId);
}
